package com.tarena.demo.luban.all.main.handler;

import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.tarena.demo.luban.commons.restful.JsonResult;
import com.tarena.demo.luban.commons.restful.ResponseCode;
import com.tarena.demo.luban.protocol.order.param.OrderAddParam;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class MyBlockHandler {

    public static JsonResult addOrderBlockHandler(OrderAddParam orderAddParam, BlockException e) {
        log.error("addOrder功能被限流了",e);
        return JsonResult.failed(ResponseCode.BAD_REQUEST,"addOrder功能被限流了");
    }

    public static JsonResult addOrderFallback(OrderAddParam orderAddParam, Throwable e) {
        log.error("addOrder功能出现了业务异常",e);
        return JsonResult.failed(ResponseCode.BAD_REQUEST,"addOrder功能出现了业务异常");
    }
}
